#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/9/27 21:40
# @Author  : leon yan
# @Site    :
# @File    : OneHeight.py
# @Software: PyCharm

from PyQt5.QtCore import pyqtSlot, pyqtSignal
from PyQt5.QtWidgets import QWidget, QApplication, QMessageBox

import Globalist as gl
from resource.OneHeight_ui import Ui_Form


class QOneHeight(QWidget, Ui_Form):
    def __init__(self, parent=None, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.setupUi(self)
        '''启动更新方法'''
        self.threadObj = gl.get_value("obj_UpdateThread")
        self.threadObj.bPulse.connect(self.do_UpdateStatus)

    def __del__(self):
        print("OneHeight is deleted")

    def closeEvent(self, event):
        pass

    @pyqtSlot()
    def on_btnClose_clicked(self):
        self.close()

    @pyqtSlot()
    def on_btnApply_clicked(self):
        pass

    @pyqtSlot()
    def do_UpdateStatus(self):
        curHeightDict = gl.global_var["curHeight"]
        aa = []
        for key, value in curHeightDict.items():
            for i in range(len(value)):
                aa.append(value[i])
        for j in range(len(aa)):
            exec("self.labHt" + str(j + 1) + ".setText('" + str(aa[j]) + "')")

        setHeightDict = gl.global_var["setHeight"]
        aa = []
        for key, value in setHeightDict.items():
            for i in range(len(value)):
                aa.append(value[i])
        for j in range(len(aa)):
            exec("self.setHt" + str(j + 1) + ".setValue(" + str(aa[j]) + ")")


if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)
    objWindow = QOneHeight()

    objWindow.show()
    sys.exit(app.exec_())
